//
//  ZSMessageController.swift
//  ZSWeibo
//
//  Created by zsj1992 on 16/4/6.
//  Copyright © 2016年 ichange. All rights reserved.
//

import UIKit

class ZSMessageController: ZSBaseViewController{

    override func viewDidLoad() {
        super.viewDidLoad()

        
        visitorView?.setVisitorViewInfo("visitordiscover_image_message", text: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem.creatItem( target: self, action: "find", title: "发现群")
        self.navigationItem.leftBarButtonItem = nil

        self.tabBarItem.badgeValue = "10"
        
//        setbadgeBackGround()
    }

    
    
    private func setbadgeBackGround() {
        //遍历 tabbar的子视图
        for subView in tabBarController!.tabBar.subviews {
            if subView.isKindOfClass(NSClassFromString("UITabBarButton")!) {
                for v in subView.subviews {
                    if v.isKindOfClass(NSClassFromString("_UIBadgeView")!) {
                        for bgView in v.subviews {
                            if bgView.isKindOfClass(NSClassFromString("_UIBadgeBackground")!) {
                                print("终于找到你,还好没放弃")
//                                print(bgView)
                                //通过KVC 来设置成员变量  打断点  通过调试台查看 成员变量
                                bgView.setValue(UIImage(named: "main_badge"), forKey: "_image")
                            }
                        }
                    }
                }
            }
        }
    }
    
    
    
    

    
  @objc private func find(){
        print("发现群")
    tabBarItem.badgeValue = "\(rand()%50)"
    }
    
}
